
public class test1 {
    //选择排序
    public static void main(String[] args) {
        int[] nums = {1,3,5,7,9,2,4,6,8,-2,0,8,6,3};
        choiceSort(nums);
        for(int n:nums){
            System.out.print(n+" ");
        }
    }
    public static void choiceSort(int[] nums){

        int min = Integer.MAX_VALUE,index = -1;
        for(int cur1 = 0;cur1<nums.length-1;cur1++){
            min = Integer.MAX_VALUE;
            index = -1;
            for(int cur2 = cur1;cur2<nums.length;cur2++){
                if(nums[cur2]<min){
                    min = nums[cur2];
                    index = cur2;
                }
            }
            int tmp = nums[cur1];
            nums[cur1] = nums[index];
            nums[index] = tmp;
        }

    }
}
